{layout name="layout/food" /}
<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title am-cf">{$title}</div>
                </div>
				<div class="widget-body am-fr">
                    <!-- 工具栏 -->
                    <div class="page_toolbar am-margin-bottom-xs am-fr">
                        <form class="toolbar-form" action="{:url('food.order/export_order')}" method="post">
                            <div class="am-u-sm-12">
                                <div class="am fr">
                                    <div class="am-form-group tpl-form-border-form am-fl">
                                        <input type="text" name="time[star]"
                                               class="am-form-field"
                                               value="" placeholder="请选择起始日期"
                                               data-am-datepicker required>
                                    </div>
                                    <div class="am-form-group tpl-form-border-form am-fl">
                                        <input type="text" name="time[end]"
                                               class="am-form-field"
                                               value="" placeholder="请选择截止日期"
                                               data-am-datepicker required>
                                    </div>
                                    <div class="am-form-group am-fl">
                                        <div class="am-btn-toolbar">
                                            <div class="am-btn-group am-btn-group-xs">
                                                <button class="am-btn am-btn-secondary am-radius" type="submit">
                                                    <span class="am-icon-download"></span> 订单导出
                                                </button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </form>
                        <form class="toolbar-form" action="{:url('food.order/all_list')}">
                            <div class="am-u-sm-12">
                                <div class="am-fr">
                                    {if $user['applet']['shop_mode']['value']==20}
                                    <div class="am-form-group am-fl">
                                        <select name="shop_id"
                                                data-am-selected="{btnSize: 'sm', placeholder: '全部门店'}">
                                            <option value=""></option>
                                            {if isset($category)}
                                                {foreach $category as $item}
                                                <option value="{$item['shop_id']}" {$shop_id == $item['shop_id'] ? 'selected' : ''}>{$item['shop_name']}</option>
                                                {/foreach}
                                            {/if}
                                        </select>
                                    </div>
                                    {/if}
                                    <div class="am-form-group am-fl">
                                        <div class="am-input-group am-input-group-sm tpl-form-border-form">
                                            <input type="text" class="am-form-field" name="search"
                                                   placeholder="请输入订单号" value="{$search}">
                                            <div class="am-input-group-btn">
                                                <button class="am-btn am-btn-default am-icon-search" type="submit"></button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="order-list am-scrollable-horizontal am-u-sm-12 am-margin-top-xs">
                        <table width="100%" class="am-table am-table-hover tpl-table-black am-table-centered am-text-nowrap am-margin-bottom-xs">
                            <thead>
                            <tr>
                                <th class="goods-detail">商品信息</th>
                                <th width="100px">单价/数量</th>
                                <th>实付款</th>
                                <th>买家</th>
                                <th>交易状态</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {if !$list->isEmpty()}
                                {foreach $list as $order}
                                <tr class="order-empty">
                                    <td colspan="6"></td>
                                </tr>
                                <tr>
                                    <td class="am-text-middle am-text-left" colspan="6">
										<span class="am-margin-right-lg">
                                            {if $order['order_mode']['value']==10 AND $order['row_no'] <> ''}
                                                # 堂食：{$order['row_no']}号 #
                                            {/if}
                                            {if $order['order_mode']['value']==30}
                                                # 自取：{$order['row_no']}号 到店时间：{$order['arrive_time']['text']}#
                                            {/if}
                                            {if $order['order_mode']['value']==20}
                                                # 外卖：{$order['row_no']}号 #
                                            {/if}
                                            {if $order['order_mode']['value']==10 AND $order['row_no'] == ''}
                                                # 餐桌/包间：{$order['table']['table_name']} - {$order['people']}人就餐 #
                                            {/if}
										</span>
										<span class="am-margin-right-lg">门店：{$order['shop']['shop_name']}</span>
                                        <span class="am-margin-right-lg">来源：{$order['source']['text']}</span>
                                        <span class="am-margin-right-lg">订单号：{$order['order_no']}</span>
                                        <span class="am-margin-right-lg">下单时间：{$order['create_time']}</span>
                                    </td>
                                </tr>
                                <?php $i = 0;?>
                                {foreach $order['goods'] as $goods}
                                <?php $i++;?>
                                    <tr>
                                        <td class="goods-detail am-text-middle">
                                            <div class="goods-image">
                                                <img src="{$goods['image']['url']}" alt="">
                                            </div>
                                            <div class="goods-info">
                                                <p class="goods-title">{$goods['goods_name']}</p>
                                                <p class="goods-spec am-link-muted">
                                                    {$goods['goods_attr']}
                                                </p>
                                            </div>
                                        </td>
                                        <td class="am-text-middle">
                                            <p>￥{$goods['goods_price']} × {$goods['total_num']}</p>
											{if $order['order_status']['value']==40}
                                            <p>退 × {$goods['refund_num']}</p>
											{/if}
                                        </td>
                                        {if $i === 1}
                                        <?php $goodsCount = count($order['goods']); ?>
                                            <td class="am-text-middle" rowspan="{$goodsCount}">
                                                <p>￥{$order['pay_price']}</p>
                                                <p class="am-link-muted">(优惠额：-￥{$order['activity_price']})</p>
												{if $order['pack_price'] > 0}
													<p class="am-link-muted">(包装费：+￥{$order['pack_price']})</p>
												{/if}
												{if $order['express_price'] > 0}
													<p class="am-link-muted">(配送费：+￥{$order['express_price']})</p>
												{/if}
                                                {if $order['ware_price'] > 0}
													<p class="am-link-muted">(餐具费：+￥{$order['ware_price']})</p>
												{/if}
												{if $order['order_status']['value'] == 40}
													<p>退款：-￥{$order['refund_price']}</p>
												{/if}
                                            </td>
                                            <td class="am-text-middle" rowspan="{$goodsCount}">
                                                <p>{$order['user']['nickname']}</p>
                                                <p class="am-link-muted">(用户id：{$order['user']['user_id']})</p>
                                            </td>
                                            <td class="am-text-middle" rowspan="{$goodsCount}">
                                                <p>付款状态：
                                                    <span class="am-badge
                                                {$order['pay_status']['value'] == 20 ? 'am-badge-success' : ''}
                                                {$order['pay_status']['value'] == 30 ? 'am-badge-danger' : ''}">
                                                        {$order['pay_status']['text']}</span>
                                                </p>
                                                <p>接单状态：
                                                    <span class="am-badge
                                                {$order['shop_status']['value'] > 10 ? 'am-badge-success' : ''}">
                                                        {$order['shop_status']['text']}</span>
                                                </p>
                                                <p>配送状态：
                                                    <span class="am-badge
                                                {$order['delivery_status']['value'] == 20 ? 'am-badge-warning' : ''}
                                                {$order['delivery_status']['value'] == 30 ? 'am-badge-success' : ''}">
                                                        {$order['delivery_status']['text']}</span>
                                                </p>
                                                <p>收货状态：
                                                    <span class="am-badge
                                                {$order['receipt_status']['value'] == 20 ? 'am-badge-success' : ''}">
                                                        {$order['receipt_status']['text']}</span>
                                                </p>
												<p>订单状态：
                                                    <span class="am-badge
                                                {$order['order_status']['value'] == 10 ? 'am-badge-warning' : ''}
												{$order['order_status']['value'] == 20 ? 'am-badge-danger' : ''}
												{$order['order_status']['value'] == 30 ? 'am-badge-success' : ''}
												{$order['order_status']['value'] == 40 ? 'am-badge-danger' : ''}">
												{$order['order_status']['value'] == 40 ? $order['refund_status']['text'] : $order['order_status']['text']}
													</span>
                                                </p>
                                            </td>
                                            <td class="am-text-middle" rowspan="{$goodsCount}">
                                                <div class="tpl-table-black-operation">
                                                    <a class="tpl-table-black-operation-green"
                                                       href="{:url('food.order/detail', ['id' => $order['order_id']])}">
                                                        订单详情</a>
                                                    {if $order['pay_status']['value'] > 10 AND $order['shop_status']['value'] == 10 AND $order['order_status']['value'] == 10}
                                                        <a class="tpl-table-black-operation"
                                                           href="{:url('food.order/detail#shop',['id' => $order['order_id']])}">
                                                            确认接单</a>
                                                    {/if}
                                                    {if $order['shop_status']['value'] == 20 AND $order['delivery_status']['value'] == 10 AND $order['order_status']['value'] == 10}
                                                        <a class="tpl-table-black-operation"
                                                           href="{:url('food.order/detail#delivery',['id' => $order['order_id']])}">
                                                            {$order['order_mode']['value']==20?'外卖推送':'确认发货'}</a>
                                                    {/if}
                                                    {if $order['order_mode']['value'] == 20 AND $order['delivery_status']['value'] == 20 AND $order['delivery']['delivery_status']['value'] == 10 AND $order['order_status']['value'] == 10}
                                                        <a class="tpl-table-black-operation"
                                                           href="{:url('food.order/detail#dev20',['id' => $order['order_id']])}">
                                                            指派骑手</a>
                                                    {/if}
                                                    {if $order['order_mode']['value'] == 20 AND $order['delivery_status']['value'] == 20 AND $order['delivery']['delivery_status']['value'] == 20 AND $order['order_status']['value'] == 10}
                                                        <a class="tpl-table-black-operation"
                                                           href="{:url('food.order/detail#dev30',['id' => $order['order_id']])}">
                                                            骑手到店</a>
                                                    {/if}
                                                    {if $order['order_mode']['value'] == 20 AND $order['delivery_status']['value'] == 20 AND $order['delivery']['delivery_status']['value'] == 30 AND $order['order_status']['value'] == 10}
                                                        <a class="tpl-table-black-operation"
                                                           href="{:url('food.order/detail#dev40',['id' => $order['order_id']])}">
                                                            外卖配送</a>
                                                    {/if}
                                                    {if $order['order_mode']['value'] == 20 AND $order['delivery_status']['value'] == 20 AND $order['delivery']['delivery_status']['value'] == 40  AND $order['order_status']['value'] == 10}
                                                        <a class="tpl-table-black-operation"
                                                           href="{:url('food.order/detail#dev50',['id' => $order['order_id']])}">
                                                            外卖送达</a>
                                                    {/if}
                                                    {if $order['pay_status']['value'] == 30 AND $order['delivery_status']['value'] == 30 AND $order['order_status']['value'] == 10}
                                                        <a class="tpl-table-black-operation"
                                                           href="{:url('food.order/detail#collection',['id' => $order['order_id']])}">
                                                            确认收款</a>
                                                    {/if}
                                                    {if $order['refund_status']['value'] == 10 AND $order['order_status']['value'] == 40}
                                                        <a class="tpl-table-black-operation-del"
                                                           href="{:url('food.order/detail#refund',['id' => $order['order_id']])}">
                                                            确认退款</a>
                                                    {/if}
                                                </div>
                                            </td>
                                        {/if}
                                    </tr>
                                {/foreach}
                            {/foreach}
                            {else /}
                                <tr>
                                    <td colspan="6" class="am-text-center">暂无记录</td>
                                </tr>
                            {/if}
                            </tbody>
                        </table>
                    </div>
                    <div class="am-u-lg-12 am-cf">
                        <div class="am-fr">{:$list->render()} </div>
                        <div class="am-fr pagination-total am-margin-right">
                            <div class="am-vertical-align-middle">总记录：{:$list->total()}</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

